/******************************************************************************
 * $Id: notebook.c,v 1.11 2004/09/22 01:14:23 jimb Exp $
 * @file
 * @author  Jim Brooks http://www.jimbrooks.org
 * @brief   Notebook functions.
 ******************************************************************************/

#include "common.h"
#include "notebook.h"

#include "widgets.h"
#include "handlers.h"

/******************************************************************************
 * Create the notebook widget (to hold the tags/modules clist widgets).
 *
 * The caller is responsible for packing this widget.
 *
 * The notebook widget will occupy the left half of the main window.
 * This functions adds several other widgets to the notebook widget,
 * which should already be created.
 *
 * @param   pWidgetScrolledTags (GLOBAL)
 *          Added to the notebook.
 * @param   pWidgetScrolledModules (GLOBAL)
 *          Added to the notebook.
 ******************************************************************************/
void
CreateNotebook( void )
{
   GtkWidget*	pWidgetLabel;
   GtkWidget*   pImage;

  /*
   * Create the notebook widget with its tabs on top.
   */
   pWidgetNotebook = gtk_notebook_new();
   gtk_notebook_set_tab_pos( GTK_NOTEBOOK(pWidgetNotebook),
                             GTK_POS_BOTTOM );
   gtk_notebook_set_scrollable( GTK_NOTEBOOK(pWidgetNotebook),
                                TRUE );
   gtk_notebook_popup_enable( GTK_NOTEBOOK(pWidgetNotebook) );

  /*
   * Part of a KLUDGE (see clist draw handler).
   */
   g_signal_connect( G_OBJECT(pWidgetNotebook),
                       "switch-page",
                       G_CALLBACK(HandlerSwitchPageNotebook),
                       NULL );

  /*
   * Add the tags clist widget (which is contained by a scrolled widget).
   */
   //pWidgetLabel = gtk_label_new(_("tags" ));
   pImage = gtk_image_new_from_file(IMAGE_DIR"tags.gif");
   gtk_notebook_append_page( GTK_NOTEBOOK(pWidgetNotebook),
                             pWidgetScrolledTags,
                             pImage );

  /*
   * Add the modules clist widget.
   */
   pWidgetLabel = gtk_label_new(_("modules" ));
   pImage = gtk_image_new_from_file(IMAGE_DIR"modules.gif");
   gtk_notebook_append_page( GTK_NOTEBOOK(pWidgetNotebook),
                             pWidgetScrolledModules,
                             pImage );

  /*
   * Add the tag-history clist widget.
   */
   //pWidgetLabel = gtk_label_new(_("history" ));
   pImage = gtk_image_new_from_file(IMAGE_DIR"history.gif");
   gtk_notebook_append_page( GTK_NOTEBOOK(pWidgetNotebook),
                             pWidgetScrolledHistory,
                             pImage );

  /*
   * Install handlers for when a notebook page gains/loses focus.
   * (Installation for search results page is defered).
   */
   InstallFocusHandlers( pWidgetNotebook );
   InstallFocusHandlers( pWidgetClistTags );
   InstallFocusHandlers( pWidgetClistModules );
   InstallFocusHandlers( pWidgetClistHistory );

   return;
}

/*****************************************************************************
 * @return Page enums (dynamic).
 *****************************************************************************/
int
NotebookPageTags( void )
{
   return 0;
}
/** @return Page enums (dynamic). */
int
NotebookPageModules( void )
{
   return 1;
}
/** @return Page enums (dynamic). */
int
NotebookPageHistory( void )
{
   return 2;
}
/** @return Page enums (dynamic). */
int
NotebookPageFunctions( void )
{
   if ( ! skipFuncTree )
      return 3;
   else
      return -1; /* oops */
}
/** @return Page enums (dynamic). */
int
NotebookPageFound( void )
{
   if ( skipFuncTree )
      return 3;
   else
      return 4;
}
//////////////////////////////////////////////////////////////
#if 0 
/*********************************************************
 * Notebook for find and func_tree
 *********************************************************/
void
CreateNotebookFind(void)
{
    GtkWidget * pWidgetLabel;
    pWidgetNotebookFind = gtk_notebook_new();
    if ( NULL == pWidgetNotebookFind )
    {
        DebugMsg("Error when create NotebookFind, May be less of mem.");
        Popop(_("Error when create NotebookFind, May be less of mem."), "Create NotebookFind error.", NULL)
        //gtk_exit(1);
        return;
     }
   gtk_notebook_set_tab_pos( GTK_NOTEBOOK(pWidgetNotebookFind),
                             GTK_POS_BOTTOM );
   gtk_notebook_set_scrollable( GTK_NOTEBOOK(pWidgetNotebookFind),
                                TRUE );
   gtk_notebook_popup_enable( GTK_NOTEBOOK(pWidgetNotebookFind) );
/*
   g_signal_connect(G_OBJECT(pWidgetNotebookFind),
                             "switch-page",
                             G_CALLBACK(xxx));
*/
   pWidgetLabel = gtk_label_new("Func_refs");
   gtk_notebook_append_page(GTK_NOTEBOOK(pWidgetNotebookFind),
                                    pWidgetScrolledModuleFunc,
                                    pWidgetLabel);
   InstallFocusHandlers( pWidgetNotebook );
#endif
   